
/*
define([
           "dashboard",
           "dashboardicon",
           "jsonrpccontroller",
           "applications/music_player/musicplayer",
           "dojo/dom-construct"
       ],

    function(dashboard, DashboardIcon, jsonRpcController, musicPlayer, domConstruct)
    {


        // Empty the body container to change context
        var emptyBody = function()
        {
            document.body.innerHTML = "";
        }

        // Displays the dashboard
        var displayDashboard = function()
        {
            emptyBody();
            document.body.appendChild(dashboard.domNode);
        }


        // Callback that display the interface of the application 'application'
        var displayApplication = function(application)
        {
            emptyBody();
            menuApplicationNameNode.innerHTML = application.name;
            document.body.appendChild(menuNode);
            document.body.appendChild(application.domNode);
        }


        // Creates the menu node that will be displayed on all the pages to help the user
        // Navigating and go back to the dashboard.
        var menuNode = domConstruct.create("div");
        var menuIconNode = domConstruct.create("div");
        var menuApplicationNameNode = domConstruct.create("span");
        menuNode.id = "MenuNode";
        menuNode.className = "unselectable";
        menuNode.appendChild(menuIconNode);
        menuNode.appendChild(menuApplicationNameNode);
        menuApplicationNameNode.id = "menuApplicationName";
        menuNode.onclick = displayDashboard;


        // Here are declared all the icons...
        var iconRocket = new DashboardIcon("Rocket", "images/rocket.png", 128, 128);
        var iconSub = new DashboardIcon("Submarine", "images/sub.png", 128, 128);
        var iconCar = new DashboardIcon("Car", "images/car.png", 128, 128);

        dashboard.addIconToCurrentDesktop(iconRocket, null, 0, 0);
        dashboard.addIconToCurrentDesktop(iconSub, null, 100, 128+10);
        dashboard.addIconToCurrentDesktop(iconCar, null, 150, (128+10)*2);

        // Finaly displays the dashboard when enter on the page
        displayDashboard();

        // Icon click callback
        iconRocket.onclick = function()
        {
            displayApplication(musicPlayer);
        };

        iconSub.onclick = function()
        {
            displayApplication(musicPlayer);
        };


    }
);*/

define([
           "dojox/mobile/Heading",
           "dojox/mobile/ScrollableView",
           "dojox/mobile/RoundRectList",
           "dojox/mobile/ListItem",
           "dojox/mobile/View",
           "applications/music_player/musicplayer"
       ],

        function(Heading, ScrollableView, RoundRectList, ListItem, View, musicPlayer)
        {
            var applicationList = [];
            var appListView = new RoundRectList();
            var appSelectorView = new ScrollableView();


            var addApplication = function(app)
            {
                applicationList.push(app);
                var appItem = new ListItem({ moveTo:app.mainView.id, label:app.name });
                appListView.addChild(appItem);
                app.mainView.placeAt(document.body);
                app.mainView.hide();
            }

            var heading = new Heading({fixed: "top", label:"Applications"});

            appSelectorView.addFixedBar(heading);

            appSelectorView.addChild(appListView);
            appSelectorView.placeAt(document.body);


            addApplication(musicPlayer);

            appSelectorView.startup();

        }
);
